﻿using Blog.Core.DTO.ViewModel.User;
using Microsoft.AspNetCore.Identity;

namespace Blog.Core.Api.HostedService
{
    /// <summary>
    /// 自定义定时服务
    /// </summary>
    public class MyHostedService : BackgroundService
    {
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="stoppingToken"></param>
        /// <returns></returns>
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            PostUserLoginDTO dto = new PostUserLoginDTO()
            {
                Login = "123",
                Pwd = "123",
            };
            int i = 1;
            //如果没停止，就一直执行
            while (!stoppingToken.IsCancellationRequested)
            {
                DoWork(dto);
            }
            return Task.CompletedTask;
        }
        /// <summary>
        /// 打印输出一句话
        /// </summary>
        /// <param name="i"></param>
        private void DoWork(PostUserLoginDTO dto)
        {
            Console.WriteLine($"{dto}",dto);
        }
    }
}
